package com.blandReid.MultiPico.Master;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class Master extends Activity {

	// Intent request codes
    private static final int REQUEST_CONNECT_DEVICE = 1;
    private static final int REQUEST_ENABLE_BT = 2;
    
	BluetoothAdapter btAdapter = null;

	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("This will become the MP-Master app.");
        setContentView(tv);
        //perform some essential bluetooth setup first
        
        // Get local Bluetooth adapter
		btAdapter = BluetoothAdapter.getDefaultAdapter();
        // If the adapter is null, then Bluetooth is not supported
        if (btAdapter == null) {
        	Log.e("JoinerThread","Fatal- Bluetooth not available.");
            return;
        }
        //check bluetooth is enabled and prompt to enable if not
        if (!btAdapter.isEnabled()) {
            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
        }
        
        
        /*
         * Now, start the two threads, one for finding new devices, one
         * for receiving messages
         */

        JoinerThread jt = new JoinerThread();
        jt.start();
        
    }
    
    
    
    
}
